<template>
  <section class="one-key-bill">
   <information-bar :c-name="cName" :tax-amount="taxAmount"> </information-bar>
    <section class="common-block-section">
      <people-tax-detail-page @taxAmountRefresh="getTaxAmount" :c-name="cName" :month="month"></people-tax-detail-page>
    </section>
  </section>
  
</template>
<script>
import informationBar from "./informationBar"
import peopleTaxDetailPage from "./peopleTaxDetailPage"
import PeopleTaxDetailPage from './peopleTaxDetailPage.vue'
export default {
  props:{
    
  },
  data(){
    return{
      cName:"",
      taxAmount:0,
      clientInfo:{},
      month:""
    }
  },
  created() {
    const data = localStorage.getItem("peopleIncomeTaxSalarys");
    if (data) {
      this.clientInfo = JSON.parse(data);
      this.cName = this.clientInfo.cName;
      this.month = this.getLastMonth();
    }
  },
  mounted(){
    this.loadData();
  },
  components:{
    informationBar,
    peopleTaxDetailPage
  },
  methods:{
    loadData(){
    // this.$http.get("/incomeTax/getSalaryMsgList", {params: {cName:this.cName, month: this.month}}).then(res=>{
    //   console.log("res;", response)
    //   if (res.code != 0) {
    //    return this.$message.error("查看详情失败！！");
    //   }
    //   this.taxAmount = response.data.incomeTax;
    // }).catch(err=>{
    //   return this.$message.error("查看详情出错！！");
    // });
    },
    getLastMonth(){
      var myDate = new Date();
      var tYear = myDate.getFullYear();
      var tMonth = myDate.getMonth();
      var m = tMonth;
      if (m==0){
        m = 12
      }
      if (m.toString().length == 1) {
          m = "0" + m;
      }
      var month = tYear + "-" + m;
      return month;
    },
    getTaxAmount(val){
      this.taxAmount = val;
    }
  }
}
</script>

<style lang="less" scoped>
  .one-key-bill{
    width:80%;
  }
</style>